<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
                                                                                                          <el-form-item label="客户号" prop="custNo">
                    <el-input
                        v-model="queryParams.custNo"
                        placeholder="请输入客户号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户邮箱" prop="customerDtoEmail">
                    <el-input
                        v-model="queryParams.customerDtoEmail"
                        placeholder="请输入客户邮箱"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户名称" prop="customerDtoName">
                    <el-input
                        v-model="queryParams.customerDtoName"
                        placeholder="请输入客户名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="客户代码" prop="customerDtoMerchantCode">
                    <el-input
                        v-model="queryParams.customerDtoMerchantCode"
                        placeholder="请输入客户代码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="供应商金额" prop="providerAmount">
                    <el-input
                        v-model="queryParams.providerAmount"
                        placeholder="请输入供应商金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付方式" prop="paymentMethod">
                    <el-input
                        v-model="queryParams.paymentMethod"
                        placeholder="请输入支付方式"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="创建时间" prop="createdOn">
                    <el-input
                        v-model="queryParams.createdOn"
                        placeholder="请输入创建时间"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="金额" prop="amount">
                    <el-input
                        v-model="queryParams.amount"
                        placeholder="请输入金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="flagged" prop="flagged">
                    <el-input
                        v-model="queryParams.flagged"
                        placeholder="请输入flagged"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="供应商代码" prop="providerCode">
                    <el-input
                        v-model="queryParams.providerCode"
                        placeholder="请输入供应商代码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="费用" prop="fee">
                    <el-input
                        v-model="queryParams.fee"
                        placeholder="请输入费用"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="币种" prop="currencyCode">
                    <el-input
                        v-model="queryParams.currencyCode"
                        placeholder="请输入币种"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="完成时间" prop="completedOn">
                    <el-input
                        v-model="queryParams.completedOn"
                        placeholder="请输入完成时间"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付备注" prop="paymentDescription">
                    <el-input
                        v-model="queryParams.paymentDescription"
                        placeholder="请输入支付备注"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="支付状态" prop="paymentStatus">
                    <el-select v-model="queryParams.paymentStatus" placeholder="请选择支付状态" clearable size="small">
                      <el-option label="请选择字典生成" value="" />
                    </el-select>
                  </el-form-item>
                                                                                                                  <el-form-item label="第三方订单号" prop="transactionReference">
                    <el-input
                        v-model="queryParams.transactionReference"
                        placeholder="请输入第三方订单号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="内部订单号" prop="paymentReference">
                    <el-input
                        v-model="queryParams.paymentReference"
                        placeholder="请输入内部订单号"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="商户码" prop="merchantCode">
                    <el-input
                        v-model="queryParams.merchantCode"
                        placeholder="请输入商户码"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="商户名称" prop="merchantName">
                    <el-input
                        v-model="queryParams.merchantName"
                        placeholder="请输入商户名称"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="应付金额" prop="payableAmount">
                    <el-input
                        v-model="queryParams.payableAmount"
                        placeholder="请输入应付金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="实付金额" prop="amountPaid">
                    <el-input
                        v-model="queryParams.amountPaid"
                        placeholder="请输入实付金额"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="是否完成" prop="completed">
                    <el-input
                        v-model="queryParams.completed"
                        placeholder="请输入是否完成"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                  <el-form-item label="状态" prop="state">
                    <el-input
                        v-model="queryParams.state"
                        placeholder="请输入状态"
                        clearable
                        size="small"
                        @keyup.enter.native="handleQuery"
                    />
                  </el-form-item>
                                                                                                                                              <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
            v-hasPermi="['bizsys:ext_monnify_reserved_order:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="success"
            plain
            icon="el-icon-edit"
            size="mini"
            :disabled="single"
            @click="handleUpdate"
            v-hasPermi="['bizsys:ext_monnify_reserved_order:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="danger"
            plain
            icon="el-icon-delete"
            size="mini"
            :disabled="multiple"
            @click="handleDelete"
            v-hasPermi="['bizsys:ext_monnify_reserved_order:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['bizsys:ext_monnify_reserved_order:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="ext_monnify_reserved_orderList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
                                                          <el-table-column label="id" align="center" prop="id" />
                                                                      <el-table-column label="客户号" align="center" prop="custNo" />
                                                                      <el-table-column label="客户邮箱" align="center" prop="customerDtoEmail" />
                                                                      <el-table-column label="客户名称" align="center" prop="customerDtoName" />
                                                                      <el-table-column label="客户代码" align="center" prop="customerDtoMerchantCode" />
                                                                      <el-table-column label="供应商金额" align="center" prop="providerAmount" />
                                                                      <el-table-column label="支付方式" align="center" prop="paymentMethod" />
                                                                      <el-table-column label="创建时间" align="center" prop="createdOn" />
                                                                      <el-table-column label="金额" align="center" prop="amount" />
                                                                      <el-table-column label="flagged" align="center" prop="flagged" />
                                                                      <el-table-column label="供应商代码" align="center" prop="providerCode" />
                                                                      <el-table-column label="费用" align="center" prop="fee" />
                                                                      <el-table-column label="币种" align="center" prop="currencyCode" />
                                                                      <el-table-column label="完成时间" align="center" prop="completedOn" />
                                                                      <el-table-column label="支付备注" align="center" prop="paymentDescription" />
                                                                      <el-table-column label="支付状态" align="center" prop="paymentStatus" />
                                                                      <el-table-column label="第三方订单号" align="center" prop="transactionReference" />
                                                                      <el-table-column label="内部订单号" align="center" prop="paymentReference" />
                                                                      <el-table-column label="商户码" align="center" prop="merchantCode" />
                                                                      <el-table-column label="商户名称" align="center" prop="merchantName" />
                                                                      <el-table-column label="应付金额" align="center" prop="payableAmount" />
                                                                      <el-table-column label="实付金额" align="center" prop="amountPaid" />
                                                                      <el-table-column label="是否完成" align="center" prop="completed" />
                                                                      <el-table-column label="状态" align="center" prop="state" />
                                                                      <el-table-column label="备注" align="center" prop="remark" />
                                                                                                                                                                                                          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleUpdate(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_reserved_order:edit']"
          >修改</el-button>
          <el-button
              size="mini"
              type="text"
              icon="el-icon-delete"
              @click="handleDelete(scope.row)"
              v-hasPermi="['bizsys:ext_monnify_reserved_order:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改虚拟账号订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
                                                                                                                                                            <el-form-item label="客户号" prop="custNo">
                          <el-input v-model="form.custNo" placeholder="请输入客户号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户邮箱" prop="customerDtoEmail">
                          <el-input v-model="form.customerDtoEmail" placeholder="请输入客户邮箱" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户名称" prop="customerDtoName">
                          <el-input v-model="form.customerDtoName" placeholder="请输入客户名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="客户代码" prop="customerDtoMerchantCode">
                          <el-input v-model="form.customerDtoMerchantCode" placeholder="请输入客户代码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="供应商金额" prop="providerAmount">
                          <el-input v-model="form.providerAmount" placeholder="请输入供应商金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付方式" prop="paymentMethod">
                          <el-input v-model="form.paymentMethod" placeholder="请输入支付方式" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="创建时间" prop="createdOn">
                          <el-input v-model="form.createdOn" placeholder="请输入创建时间" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="金额" prop="amount">
                          <el-input v-model="form.amount" placeholder="请输入金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="flagged" prop="flagged">
                          <el-input v-model="form.flagged" placeholder="请输入flagged" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="供应商代码" prop="providerCode">
                          <el-input v-model="form.providerCode" placeholder="请输入供应商代码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="费用" prop="fee">
                          <el-input v-model="form.fee" placeholder="请输入费用" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="币种" prop="currencyCode">
                          <el-input v-model="form.currencyCode" placeholder="请输入币种" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="完成时间" prop="completedOn">
                          <el-input v-model="form.completedOn" placeholder="请输入完成时间" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付备注" prop="paymentDescription">
                          <el-input v-model="form.paymentDescription" placeholder="请输入支付备注" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="支付状态">
                          <el-radio-group v-model="form.paymentStatus">
                            <el-radio label="1">请选择字典生成</el-radio>
                          </el-radio-group>
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="第三方订单号" prop="transactionReference">
                          <el-input v-model="form.transactionReference" placeholder="请输入第三方订单号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="内部订单号" prop="paymentReference">
                          <el-input v-model="form.paymentReference" placeholder="请输入内部订单号" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="商户码" prop="merchantCode">
                          <el-input v-model="form.merchantCode" placeholder="请输入商户码" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="商户名称" prop="merchantName">
                          <el-input v-model="form.merchantName" placeholder="请输入商户名称" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="应付金额" prop="payableAmount">
                          <el-input v-model="form.payableAmount" placeholder="请输入应付金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="实付金额" prop="amountPaid">
                          <el-input v-model="form.amountPaid" placeholder="请输入实付金额" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="是否完成" prop="completed">
                          <el-input v-model="form.completed" placeholder="请输入是否完成" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="状态" prop="state">
                          <el-input v-model="form.state" placeholder="请输入状态" />
                        </el-form-item>
                                                                                                                                                                                          <el-form-item label="备注" prop="remark">
                          <el-input v-model="form.remark" placeholder="请输入备注" />
                        </el-form-item>
                                                                                                                                                                                                                                                                                                                </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import { listExt_monnify_reserved_order, getExt_monnify_reserved_order, delExt_monnify_reserved_order, addExt_monnify_reserved_order, updateExt_monnify_reserved_order, exportExt_monnify_reserved_order } from "@/api/bizsys/ext_monnify_reserved_order";

  export default {
    name: "Ext_monnify_reserved_order",
    components: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        },
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
                  // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 虚拟账号订单表格数据
              ext_monnify_reserved_orderList: [],
                  // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
                                                                                custNo: null,
                                                                    customerDtoEmail: null,
                                                                    customerDtoName: null,
                                                                    customerDtoMerchantCode: null,
                                                                    providerAmount: null,
                                                                    paymentMethod: null,
                                                                    createdOn: null,
                                                                    amount: null,
                                                                    flagged: null,
                                                                    providerCode: null,
                                                                    fee: null,
                                                                    currencyCode: null,
                                                                    completedOn: null,
                                                                    paymentDescription: null,
                                                                    paymentStatus: null,
                                                                    transactionReference: null,
                                                                    paymentReference: null,
                                                                    merchantCode: null,
                                                                    merchantName: null,
                                                                    payableAmount: null,
                                                                    amountPaid: null,
                                                                    completed: null,
                                                                    state: null,
                                                                                                                                                                                },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    createTime: [
                    { required: true, message: "创建时间不能为空", trigger: "blur" }
                  ],
                                                                                                                                        updateTime: [
                    { required: true, message: "更新时间不能为空", trigger: "blur" }
                  ]
                                    }
      };
    },
    created() {
      // this.getList();
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                },
    methods: {
      /** 查询虚拟账号订单列表 */
      getList() {
        this.loading = true;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            listExt_monnify_reserved_order(this.queryParams).then(response => {
          this.ext_monnify_reserved_orderList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
                                                    id: null,
                                                                    custNo: null,
                                                                    customerDtoEmail: null,
                                                                    customerDtoName: null,
                                                                    customerDtoMerchantCode: null,
                                                                    providerAmount: null,
                                                                    paymentMethod: null,
                                                                    createdOn: null,
                                                                    amount: null,
                                                                    flagged: null,
                                                                    providerCode: null,
                                                                    fee: null,
                                                                    currencyCode: null,
                                                                    completedOn: null,
                                                                    paymentDescription: null,
                                                                paymentStatus: "0",
                                                                    transactionReference: null,
                                                                    paymentReference: null,
                                                                    merchantCode: null,
                                                                    merchantName: null,
                                                                    payableAmount: null,
                                                                    amountPaid: null,
                                                                    completed: null,
                                                                    state: null,
                                                                    remark: null,
                                                                    createBy: null,
                                                                    createTime: null,
                                                                    updateBy: null,
                                                                    updateTime: null
                                    };
                  this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.open = true;
        this.title = "添加虚拟账号订单";
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        const id = row.id || this.ids
        getExt_monnify_reserved_order(id).then(response => {
          this.form = response.data;
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              this.open = true;
          this.title = "修改虚拟账号订单";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate(valid => {
          if (valid) {
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        if (this.form.id != null) {
              updateExt_monnify_reserved_order(this.form).then(response => {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              });
            } else {
              addExt_monnify_reserved_order(this.form).then(response => {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm('是否确认删除虚拟账号订单编号为"' + ids + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delExt_monnify_reserved_order(ids);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
      },
              /** 导出按钮操作 */
      handleExport() {
        const queryParams = this.queryParams;
        this.$confirm('是否确认导出所有虚拟账号订单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportExt_monnify_reserved_order(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
      }
    }
  };
</script>
